DEF wnd:PTR TO window,file:PTR TO CHAR,names:PTR TO LONG,scr:PTR TO screen
DEF menus=NIL:PTR TO menu
DEF ok=FALSE
DEF left=0,right=0,move=0,key=0
-> main() - get args, and call main0()
PROC main()
DEF rda:PTR TO rdargs,a[1]:ARRAY OF LONG,out,in
DEF sm:PTR TO wbstartup,cd,sm_numargs
names:=['LEFT','RIGHT','MOVE','KEY']
IF gadtoolsbase:=OpenLibrary('gadtools.library',0)
menus:=CreateMenusA(
[1,0,'Stats',0,0,0,0,
2,0,'Left button','1',0,0,0,
2,0,'Right button','2',0,0,0,
2,0,'Mouse movement','3',0,0,0,
2,0,'Keyboard','4',0,0,0,
2,0,-1,0,0,0,0,
2,0,'Quit','Q',0,0,0,
0,0,NIL,0,0,0,0]:newmenu,
[0])
ENDIF
sm:=wbmessage
sm_numargs:=IF sm THEN sm.numargs ELSE 0
IF sm_numargs=1
WriteF('Please enter file name: ')
ENDIF
in:=SelectInput(IF stdin THEN stdin ELSE stdout)
out:=SelectOutput(stdout)
a[0]:=NIL
IF sm_numargs<=1
IF rda:=ReadArgs('FILE/A',a,NIL)
file:=a[0]
main0()
FreeArgs(rda)
ELSE
PrintFault(IoErr(),NIL)
ENDIF
ELSE
IF sm.arglist[1].lock
cd:=CurrentDir(sm.arglist[1].lock)
file:=sm.arglist[1].name
main0()
CurrentDir(cd)
ENDIF
ENDIF
SelectInput(in)
SelectOutput(out)
IF ok
Close(conout)
conout:=0
ENDIF
IF gadtoolsbase
IF menus THEN FreeMenus(menus)
CloseLibrary(gadtoolsbase)
ENDIF
ENDPROC
-> main0() - main loop
PROC main0()
DEF class,code,done=FALSE,col,vis,item:PTR TO menuitem,cmd,imsgCode,menunumber
IF scr:=LockPubScreen(NIL)
IF wnd:=OpenW(0,0,scr.width,scr.height,IDCMP_CLOSEWINDOW OR IDCMP_VANILLAKEY OR IDCMP_NEWSIZE OR IDCMP_MENUPICK,WFLG_ACTIVATE OR WFLG_CLOSEGADGET OR WFLG_DRAGBAR OR WFLG_DEPTHGADGET OR WFLG_HASZOOM,'AStats',scr,CUSTOMSCREEN,NIL,[WA_ZOOM,[0,11,200,100]:ibox,WA_NEWLOOKMENUS,TRUE,TAG_DONE])